﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using GraphCompiler.Core;
using GraphCompiler.Core.SyntaxRepresentation;

namespace GraphCompiler.Specification.SyntaxRepresentation
{
    [TestFixture]
    public class SyntaxNodeSpecs
    {
        [Test]
        public void ConsidersNodeEqualToItself()
        {
            var syntaxNode = new TestNode();

            Assert.AreEqual(syntaxNode, syntaxNode);
        }

        [Test]
        public void ConsidersEmptyNodeEqualToOtherEmptyNode()
        {
            var emptyTestNode1 = new TestNode();
            var emptyTestNode2 = new TestNode();

            Assert.AreEqual(emptyTestNode1, emptyTestNode2);
        }

        [Test]
        public void DoesNotConsiderEmptyNodeEqualToNonEmptyNode()
        {
            var emptyTestNode = new TestNode();
            var nonEmptyTestNode = new TestNode();
            nonEmptyTestNode.AddChild(new DiagramNode());

            Assert.AreNotEqual(emptyTestNode, nonEmptyTestNode);
        }

        [Test]
        public void ConsidersNodeWithSameNodesEqual()
        {
            var syntaxNode1 = new TestNode();
            var syntaxNode2 = new TestNode();

            var node1 = new DiagramNode();
            var node2 = new DiagramNode();

            syntaxNode1.AddChild(node1);
            syntaxNode1.AddChild(node2);
            syntaxNode2.AddChild(node1);
            syntaxNode2.AddChild(node2);

            Assert.AreEqual(syntaxNode1, syntaxNode2);
        }

        [Test]
        public void ConsidersNodeWithEqualNodesEqual()
        {
            var syntaxNode1 = new TestNode();
            var syntaxNode2 = new TestNode();

            syntaxNode1.AddChild(new DiagramNode());
            syntaxNode2.AddChild(new DiagramNode());

            Assert.AreEqual(syntaxNode1, syntaxNode2);
        }

        class TestNode : SyntaxNode
        {

        }
    }
}
